import java.util.*;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}


class Node {
    public int val;
    public Node left;
    public Node right;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val,Node _left,Node _right) {
        val = _val;
        left = _left;
        right = _right;
    }
};

class Main{
    static int i=0;
    public static Node createTree(String str){
        if(str==null){
            return null;
        }
        char ch=str.charAt(i);
        Node root=null;
        if(ch!='#'){
            root=new Node(ch);
            i++;
            root.left=createTree(str);
            root.right=createTree(str);
        }else{
            i++;
        }
        return root;
    }
    public static void inorder(Node root){
        if(root==null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val);
        inorder(root.right);
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        while(scan.hasNext()){
            String str=scan.nextLine();
            Node root=createTree(str);
            inorder(root);
        }
    }
}






class Solution1 {
    public int index=0;
    public TreeNode buildTreeChild(int[] preorder,int[] inorder,int begin,int end){
        if(begin>end){
            return null;
        }
        TreeNode root=new TreeNode(preorder[index]);
        int rootIndex=findInorderIndex(inorder,begin,end,preorder[index]);
        index--;
        root.right=buildTreeChild(preorder,inorder,rootIndex+1,end);
        root.left=buildTreeChild(preorder,inorder,begin,rootIndex-1);
        return root;

    }
    public int findInorderIndex(int[] inorder,int begin,int end,int key){
        for(int i=begin;i<=end;i++){
            if(inorder[i]==key){
                return i;
            }
        }
        return -1;
    }
    public TreeNode buildTree(int[] inorder, int[] postorder) {
        if(postorder==null||inorder==null){
            return null;
        }
        index=inorder.length-1;
        return buildTreeChild(postorder,inorder,0,inorder.length-1);
    }
}






class Solution {










    public int index=0;
    public TreeNode buildTreeChild(int[] preorder,int[] inorder,int begin,int end){
        if(begin>end){
            return null;
        }
        TreeNode root=new TreeNode(preorder[index]);
        index++;
        int rootIndex=findInorderIndex(inorder,begin,end,preorder[index]);
        root.left=buildTreeChild(preorder,inorder,begin,rootIndex-1);
        root.right=buildTreeChild(preorder,inorder,rootIndex+1,end);
        return root;

    }
    public int findInorderIndex(int[] inorder,int begin,int end,int key){
        for(int i=begin;i<end;i++){
            if(inorder[i]==key){
                return i;
            }
        }
        return -1;
    }
    public TreeNode buildTree(int[] preorder, int[] inorder) {
        if(preorder==null||inorder==null){
            return null;
        }
        return buildTreeChild(preorder,inorder,0,inorder.length-1);
    }










    Node prev=null;
    Node tail=null;
    public void treeToDoublyLists(Node cur){
        if(cur==null){
            return;
        }
        treeToDoublyLists(cur.left);
        cur.left=prev;
        if(prev==null){
            prev=cur;
        }else{
            prev.right=cur;
            prev=cur;
        }
        treeToDoublyLists(cur.right);
    }
    public Node treeToDoublyList(Node root) {
        if(root==null){
            return null;
        }
        treeToDoublyLists(root);
        tail=prev;
        while(root.left!=null){
            root= root.left;
        }
        tail.right=root;
        root.left=tail;
        return root;
    }






    TreeNode prev1=null;
    public void Converts(TreeNode pcur){
        if(pcur==null) {
            return ;
        }
        Converts(pcur.left);
        pcur.left=prev1;
        if(prev1==null){
            prev1=pcur;
        }else{
            prev1.right=pcur;
            prev1=pcur;
        }
        Converts(pcur.right);
    }
    public TreeNode Convert(TreeNode pRootOfTree) {
        if(pRootOfTree==null){
            return null;
        }
        Converts(pRootOfTree);
        while(pRootOfTree.left!=null){
            pRootOfTree=pRootOfTree.left;
        }
        return pRootOfTree;
    }







    public List<List<Integer>> levelOrder(TreeNode root) {
        List<List<Integer>> list=new ArrayList<>();
        Queue<TreeNode> queue=new ArrayDeque<>();
        if(root!=null){
            queue.offer(root);
            while(!queue.isEmpty()){
                int size=queue.size();
                List<Integer> arr=new ArrayList<>();
                for(int i=0;i<size;i++){
                    TreeNode tmp=queue.poll();
                    arr.add(tmp.val);
                    if(tmp.left!=null){
                        queue.offer(tmp.left);
                    }
                    if(tmp.right!=null){
                        queue.offer(tmp.right);
                    }
                }
                list.add(arr);
            }
        }
        return list;
    }







    public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
        if(root==null){
            return null;
        }
        if(root==p||root==q){
            return root;
        }
        TreeNode left=lowestCommonAncestor(root.left,p,q);
        TreeNode right=lowestCommonAncestor(root.right,p,q);
        if(left!=null){
            return left;
        }
        if(right!=null){
            return right;
        }
        return null;
    }






    public String tree2str(TreeNode root) {
        if(root==null){
            return "";
        }
        if(root.left==null&&root.right==null){
            return root.val+"";
        }
        if(root.right==null){
            return root.val+"("+tree2str(root.right)+")";
        }
        return root.val+"("+tree2str(root.left)+")"+"("+tree2str(root.right)+")";
    }








    public boolean isCompleteTree(TreeNode root) {
        Queue<TreeNode> queue=new LinkedList<>();
        if (root!=null){
            queue.offer(root);
            TreeNode tmp;
            while((tmp=queue.poll())!=null){
                queue.offer(tmp.left);
                queue.offer(tmp.right);
            }
            for(TreeNode T:queue){
                if(T!=null){
                    return false;
                }
            }
        }
        return  true;
    }





    public List<List<Integer>> levelOrder1(TreeNode root) {
        List<List<Integer>> list=new ArrayList<>();
        Queue<TreeNode> queue=new ArrayDeque<>();
        if(root!=null){
            queue.offer(root);
            while(!queue.isEmpty()){
                List<Integer> arr=new ArrayList<>();
                int size=queue.size();
                for(int i=0;i<size;i++){
                    TreeNode tmp=queue.poll();
                    arr.add(tmp.val);
                    if(tmp.left!=null){
                        queue.offer(tmp.left);
                    }
                    if(tmp.right!=null){
                        queue.offer(tmp.right);
                    }
                }
                list.add(arr);
            }
        }
        return list;
    }






    public boolean dfs(TreeNode p,TreeNode q){
        if(p==null&&q==null){
            return true;
        }
        if(p==null||q==null){
            return false;
        }
        return p.val==q.val&&dfs(p.left,q.right)&&dfs(p.right,q.left);
    }
    public boolean isSymmetric(TreeNode root) {
        return dfs(root.left,root.right);
    }






    public int dfs1(TreeNode root){
        if(root==null){
            return 0;
        }
        int left=dfs1(root.left);
        int right=dfs1(root.right);
        if(left>=0&&right>=0&&Math.abs(left-right)<2){
            return Math.max(left,right)+1;
        }
        return -1;
    }
    public boolean isBalanced(TreeNode root) {
        return dfs1(root)<0?false:true;
    }







    public boolean isSubtree(TreeNode root, TreeNode subRoot) {
        if(root==null||subRoot==null){
            return false;
        }
        if(isSameTree(root,subRoot)){
            return true;
        }
        if(isSubtree(root.left,subRoot)){
            return true;
        }
        if(isSubtree(root.right,subRoot)){
            return true;
        }
        return false;
    }







    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null&&q==null){
            return true;
        }else if(p==null||q==null){
            return false;
        }else if(p.val!=q.val){
            return false;
        }
        return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);
    }






    public int widthOfBinaryTree(TreeNode root) {
        if(root==null){
            return 0;
        }
        Deque<TreeNode> queue=new ArrayDeque<>();
        root.val=0;
        queue.offer(root);
        int index=Integer.MIN_VALUE;
        while(!queue.isEmpty()){
            int size=queue.size();
            index=Math.max(index,queue.getLast().val-queue.getFirst().val+1);
            for(int i=0;i<size;i++){
                TreeNode tmp=queue.poll();
                if(tmp.left!=null){
                    tmp.left.val=tmp.val*2;
                    queue.offer(tmp.left);
                }
                if(tmp.right!=null){
                    tmp.right.val=tmp.val*2+1;
                    queue.offer(tmp.right);
                }
            }
        }
        return index;
    }






    public boolean isCompleteTree1(TreeNode root) {
        Queue<TreeNode> queue=new LinkedList<>();
        if(root!=null){
            queue.offer(root);
            TreeNode tmp;
            while((tmp=queue.poll())!=null){
                queue.offer(tmp.left);
                queue.offer(tmp.right);
            }
            for(TreeNode n : queue){
                if(n!=null){
                    return false;
                }
            }
        }
        return true;
    }
}






public class prog {
}
